#pragma once
#include "xEvent.h"
class xFrame;
class xControl
{
public:
	xControl();
	virtual ~xControl();
protected:
	LPCWSTR				m_pClassName;
	RECT				m_rect;
	xRenderTarget		*m_pRenderTarget;
	xBitmapRenderTarget *m_pBackBuffer;
	xBitmap				*m_pBackBmp;
	xBrush				*m_pBgmBrush,
						*m_pFrameBrush;
	BOOL				m_bMouseEnter;
	BOOL				m_bRedraw;
public:
	virtual	void OnRender();
	virtual	void OnDraw();
	virtual BOOL OnWndProc(UINT message, WPARAM wParam, LPARAM lParam);
	virtual void Delegate(DWORD dwEvent, xFrame *pFrame, FnEvent fnEvent);
	virtual void Reset(ID2D1RenderTarget *pRenderTarget, BOOL bReleaseOnly);
protected:
	virtual void OnLButtonDown(UINT nFlags, POINT point);
	virtual void OnLButtonUp(UINT nFlags, POINT point);
	virtual void OnMouseEnter();
	virtual void OnMouseLeave();
private:
	void	Release();
public:
	void	Create(const RECT &rect, ID2D1RenderTarget *pRenderTarget);
};